home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Resources / Online / Term / Extras / Source / gtlayout-source.lha / LTP_AdjustItemPosition.c < prev    next >
C/C++ Source or Header  |  1996-03-18  |  1KB  |  57 lines

  1. /*
  2. **    GadTools layout toolkit
  3. **
  4. **    Copyright © 1993-1996 by Olaf `Olsen' Barthel
  5. **        Freely distributable.
  6. **
  7. **    :ts=4
  8. */
  9.  
  10. #ifndef _GTLAYOUT_GLOBAL_H
  11. #include "gtlayout_global.h"
  12. #endif
  13.  
  14. #ifdef DO_MENUS
  15.  
  16.     /* LTP_AdjustItemPosition(struct MenuItem *Item,WORD Left,WORD Top):
  17.      *
  18.      *    Calculate the effective positions of the menu items.
  19.      */
  20.  
  21. LONG
  22. LTP_AdjustItemPosition(struct MenuItem *Item,LONG Left,LONG Top)
  23. {
  24.     ItemNode    *Node;
  25.     LONG         Width = 0;
  26.  
  27.         // Hit the road, Jack...
  28.  
  29.     while(Item)
  30.     {
  31.             // Get back
  32.  
  33.         Node = (ItemNode *)((ULONG)Item - sizeof(struct MinNode));
  34.  
  35.             // Add up the left edge
  36.  
  37.         Node->Left    = Left    + Node->Item.LeftEdge;
  38.         Node->Top    = Top    + Node->Item.TopEdge;
  39.  
  40.             // Fix up the sub menu
  41.  
  42.         if(Node->Item.SubItem)
  43.             Node->Width = LTP_AdjustItemPosition(Node->Item.SubItem,Node->Left,Node->Top);
  44.  
  45.             // Update the local width
  46.  
  47.         if(Node->Item.LeftEdge + Node->Item.Width > Width)
  48.             Width = Node->Item.LeftEdge + Node->Item.Width;
  49.  
  50.         Item = Item->NextItem;
  51.     }
  52.  
  53.     return(Width);
  54. }
  55.  
  56. #endif    /* DO_MENUS */
  57.